Repository navigation
Conversation
A model served by another machine can be reached today by a hand-written
llama-swap entry: a placeholder cmd, an explicit proxy, a checkEndpoint.
The console read such an entry as a local one: makeRoom sized "the whole
card" for it and freed -- or waited on -- every ComfyUI on the machine
before any request naming it, and readModels polled /props on the
foreign server twice a poll as if it were llama-server. Neither helps
the model, and both cost the machine.
Recognise the form (a proxy that is explicit, not loopback, and carries
no ${PORT} or macro) as llamaswap.Store.RemoteProxy, keep makeRoom out
of such entries, and stop polling them as llama-server.
docs/remote-models.md records the entry, measured against llama-swap
v273 with the OpenAI-API stub it forwards to, and the MLX section of
adding-a-gpu-vendor.md points at it: until that port exists, this is
how a server on another platform joins the machine.
The guard in makeRoom asks RemoteProxy on every /v1 request that names a model, and parsing the YAML there would charge a parse per request for something that changes once a config edit. Cache the remote view between file changes exactly as CanonicalModel caches the aliases: same mtime stamp, same lock, same failure behaviour.
The recipe was written from the protocol and measured against a stub; now it has been run end to end -- a Linux console, llama-swap v273, and Yunshu on an Apple Silicon Mac serving Qwen3-4B-MLX-4bit -- through chat (streaming and not), the legacy completions, Anthropic messages and count_tokens, a tool call, unload and reload, and the admin and member accounts. useModelName joins the example: servers that check the model field refuse the entry's id otherwise.
… are The recipe in docs/remote-models.md worked only as hand-written YAML and the Models page then filed it under llama.cpp -- a lie about where the weights are. The form now asks where the model lives (本機模型 or 遠端服務器) and its answer retires the fields a server elsewhere makes meaningless: file, card, context, layers, quantisation. Upsert writes the documented shape -- placeholder cmd, explicit proxy, useModelName, health check -- ReadSpec reads the same fields back, and one rule (the RemoteProxy view, already what makeRoom and the /props guard use) decides everywhere: ProviderKeys, the group dropdown and the table's tag all say 遠端模型; the Engines page keeps its three installable records; a moved-back-to-local entry loses the keys the console wrote and nobody's hand-written proxy is ever touched. Loopback with the placeholder (ssh -L, a tailscale serve) is remote; loopback without it is still a local server on a fixed port, as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
A model can live on another machine: llama-swap's
proxy:alreadyforwards to a server elsewhere, and OpenRouter needs no hardware at all.
Until now the console had no shape for that. Such entries were read as
local llama.cpp models: the Models page grouped them under llama.cpp,
every
/v1request ranmakeRoomfor them -- pausing and unloadinglocal models, and possibly freeing a ComfyUI mid-image, to make room on
this machine for a model this machine does not start -- and the props
poller walked their
/propson each request.Four commits, each one thing:
1. Never make room on this machine for a model it does not start.
llamaswap.Store.RemoteProxyanswers "which URL does this entryforward to" -- an explicit proxy that is not loopback, or loopback with
the lifecycle placeholder (an ssh -L or tailscale tunnel).
makeRoomskips those entries;
readModelsstops polling their/props. Aloopback proxy without the placeholder stays what it was: a local
server on a fixed port. The rule is deliberately conservative -- a
fixed-port llama.cpp on 127.0.0.1 with a hand-written proxy could take
the same answer and would be safe; the reverse (treating a remote entry
as local) frees VRAM nobody owns.
2. Read the answer once per config change, not once per request.
Same mtime-cache pattern as
CanonicalModel, same invalidation.3.
docs/remote-models.md: the config shape and what is measured.The entry (placeholder cmd that anchors llama-swap's lifecycle, the
proxy,
useModelNamefor servers that validate the model field, ahealth check), what the console owns (load/unload of the forwarding
side, /v1, bench of the whole path) and what it never does (install,
GPU-place, poll, evict for it), and a pairing run with a real Mac
engine: an A/B shows the unpatched console hitting the upstream 8 times
per 8 requests, the patched one 0.
4. The model editor adds remote servers too, and the list says what they are.
The form asks where the model lives (本機模型 / 遠端服務器) and its answer
retires the fields a server elsewhere makes meaningless: file, card,
context, layers, quantisation. Upsert writes the documented shape,
ReadSpec reads it back, and one rule --
RemoteProxy, the same viewcommits 1 and 2 use -- decides everywhere: the Models page groups these
under their own 遠端模型 engine rather than lying that they are
llama.cpp; the Engines page keeps its three installable records; a
moved-back-to-local entry loses the keys the console wrote, and nobody's
hand-written proxy is ever touched.
Measured end to end (Mac engine behind a relay, llama-swap v273, patched
console): create via the form -> config written -> spec read back ->
chat answers; OpenAI stream and non-stream, aliases, legacy
completions, Anthropic
/v1/messagesandcount_tokens, tools; API-keyauthz, admin/member split; unload-all and reload; edit name+URL round
trip; delete (no files, siblings untouched); a quick-tier bench run
against a remote entry, 6/6, real numbers (ttft 1.26 s, prompt 807
tok/s, gen 71 tok/s),
/v1paused and resumed around it. Full Gosuite green (31 packages, postgres 17);
go vet; web tsc and buildgreen, no new lint warnings.
Known and documented in the doc's limits: a model entry cannot carry an
Authorization header (serve on a network you trust, or bring a tunnel);
bench times the whole path, network included; the ComfyUI-eviction guard
is unit-covered but this machine has no GPU to race it for real; and
because the placeholder loads instantly, a remote entry reads as loaded
until llama-swap is told otherwise.
Why this is not an engine is written in the doc: nothing to install, no
card to place it on. What it is instead is the first rung of the ladder
#1 sketches -- remote kind, then a console that runs where the engine
is, then host-runtime engines, then whatever apple vendor follows --
each one mergeable on its own, and the unified-memory question the
vendor doc poses never has to be answered for the first rung at all.